<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/common.jspf" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>

</head>
<script type="application/javascript">

    $(document).ready(function(){
        var win = parent.$("iframe[title='订单管理']").get(0).contentWindow;
        var row = win.$("#dg").datagrid("getSelected");
        // var row1 = win.$("#detail").datagrid("getSelected");
        // alert(row.orderNum);
        $("#store").val(row.conpanyId);
        $("#deskid").val(row.deskId);
        $("#deskname").val(row.deskName);
        $("#ordernum").val(row.orderNum);
        $("#pay").val(row.orderTruepay);


        $('#bb').datagrid({
            url:"${proPath}/order/detail.action",
            queryParams: {
                simpleOrder: row.orderNum,
                orderState:1
                },

            columns:[[
                {checkbox: true},
                {field:'orderNum',title:'订单号',width:100},
                {field:'goodName',title:'商品名字',width:100},
                {field:'goodNum',title:'商品数量',width:100},
                {field:'goodPrice',title:'总价格',width:100},
                {field:'orderState',title:'菜品状态',width:100,formatter:rowformater},
                {field:'payForm',title:'付款形式',width:100},
                {field:'deskId',title:'桌号',width:100,align:'right'},
            ]],
            striped:true,
            rownumbers:true,
            pagination:true,
            pageSize:2,
            pageList:[1,2,3,4,5]
        });

    });

    function fan() {
        //关闭窗口即可就看
        parent.$('#win').window('close');
    };

    function rowformater(value, row, index) {
        // alert(value);
        if (value==1){
            value="未付款"
        }else if (value==2){
            value="已付款"
        }
        return value

    }


    function jie() {
        //获取父页面相关信息 获取订单号
        /*   var win = parent.$("iframe[title='订单管理']").get(0).contentWindow;
         var row = win.$("#dg").datagrid("getSelected");
         var orderNum = row.orderNum;

         //判断订单状态 1代表未付款
         var orderState=row.orderState;*/
        var row1= $("#bb").datagrid("getSelected");
        //alert(row.orderNum);


        $.post(
            "${proPath}/order/dan.action",
            {orderNum:row1.orderNum},
            function (data) {
                alert("结款成功");
                //修改订单状态
                //  parent.$('#win').window('close');
                $("#dg").datagrid("reload");
                /* var a=$("#bb").datagrid("getData");
                 alert(a);*/
                //win.$("#dg").datagrid("reload");


            },
            "json"
        )
        //再次查询如果为空修改订单状态

        $.post(
            "${proPath}/order/detail.action",
            {simpleOrder:row.orderNum,
                orderState:null
            },
            function (data) {
                alert(data);
                if(null == data && "" == data){
                    alert("没有可以结算的订单明细，修改订单")
                }
            },
            "json"
        )

    }

</script>

<body>


公司名字：<input id="store" type="text" class="easyui-validatebox">
餐桌号:<input id="deskid" type="text" value="" class="easyui-validatebox">
餐桌名字:<input id="deskname" type="text" value="" class="easyui-validatebox"><br>
订单号:<input id="ordernum" type="text" value="" class="easyui-validatebox">
付款金额:<input id="pay" type="text" value="" class="easyui-validatebox">
付款方式：<select id="bm" class="easyui-combobox" name="dept" style="width:200px;">
    <option value="aa">微信</option>
    <option>支付宝</option>
    <option>现金</option>

</select>

<div class="easyui-panel" title="结算页面">
    <table id="bb"></table>
    <a  href="" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="jie()">结算</a>
    <a   class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="fan()">返回</a><br>
</div>
<input type="button" onclick="ad()">

</body>
<script>


</script>
</html>
